<?php /*
<script>
$(document).ready(function() {
	function handler(event) {
		var $target = $(event.target);
		while($target.is('input')) {
			$target = $target.parent();
		}
		alert('target is ' + $target.attr('class'));
		if($target.attr('class') == "hiddenattribute") {
			$target.children().slideDown();
			$target.addClass('attribute').removeClass('hiddenattribute');
		}
		else if($target.attr('class') == "attribute") {
			$target.children().slideUp();	
			$target.addClass('hiddenattribute').removeClass('attribute');
		}
			
	}
	$(".hiddenattribute").click(handler).find(".values").hide();
});
</script>
*/ ?>

<?php defined('SYSPATH') or die('No direct script access.'); ?>
<?php $_POST['category_id'] = $category->id; ?>
<?php echo Form::open('admin/merchmanagement/items/save',
		array('method' => 'POST', 'enctype' => 'multipart/form-data'))?>
<?php echo Form::hidden('category_id', $category->id);?>
<?php echo Form::label('name', 'Name');?>
<?php echo Form::input('name', $item->name);?>
<?php echo Form::label('price', 'Price');?>
<?php echo Form::input('price', $item->price);?>
<br><br>

<?php echo Form::label('description', 'Description');?>
<?php echo Form::textarea('description', $item->description);?>
<h3>Image</h3>
<?php echo Form::label('image', 'Choose File');?>
<?php echo Form::file('image', array('name' => 'image'));?>
<br><br>
<h3>Attributes</h3>
<?php $attr_count = 0;?>
<?php foreach($attributes as $attr):?>
<h4>
<?php echo Form::checkbox('attr'.$attr->id, $attr->id, FALSE,
		array('id' => 'attr'.$attr->id, 'class' => 'attribute'));?>
<?php echo $attr->name; ?></h4>
<ul>
<?php $value_count = 0;?>
<?php foreach($attr->values->find_all() as $val):?>
<li>
<?php echo Form::checkbox('value'.$val->id, $val->id, FALSE,
		array('class' => 'valueofattr'.$attr->id));?>
<?php echo $val->value;?>
</li>
<?php endforeach;?>
</ul>
<?php endforeach;?>
<?php echo Form::submit('submit', 'Submit')?>
<?php echo Form::close();?>
<br>
<br>